<?php
include "../inc-config.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Search Posts</title>
<style type="text/css">
<!--
body {
	background-color: #000000;
	background-image: url(../images/alliance-tile.jpg); background-repeat:repeat-x;
}
body,td,th {
	color: #CC9900;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 13px;
}
a:link {
    color:#CC9900; 
	
	
}
a:visited {
    color:#CC9900;
	
}
a:hover {
    color:#ffffff;
}
a:active {
    color:#FF0000;
}
#tr { background:transparent; background-image:url(../images/transp.png); color:#FFFFFF; border: 1px solid #333333}
input { background:transparent; background-image:url(../images/transp.png); color:#FFFFFF; border: 1px solid #333333}
select { background-color:#000000; color:#FFFFFF; border: 1px solid #333333}
textarea { background-color:#000000; color:#FFFFFF; border: 1px solid #333333}
.style1 {
	font-size: 14px;
	font-weight: bold;
}
.style2 {color: #FFFFFF}

-->
</style></head>

<body>

<center>
<?php
if(isset($_POST['submit'])||isset($_POST['searchterm'])||isset($_GET['searchterm']))
{
  if(!isset($start))
  {
    $start=0;
  }
  else
  {
    $start=$_GET['start'];
  }
  if(isset($_GET['searchterm']))
  {
    $searchterm=$_GET['searchterm'];
  }
  else
  {
    $searchterm=$_POST['searchterm'];
  }
  print "<br><br><br><br><table style='background-image:url(../images/transp.png); border: solid 1px #000000; width: 500px;  padding-bottom: 10px'>";
  print "<tr><td colspan='2'><div style='background-image: url(../images/transpblack.png); padding: 2px'><center><strong class='style1'>Topics</strong></center></div></td></tr>";
  $searchterm=$_POST['searchterm'];
  $getthreads="SELECT * from b_posts where  post like '%$searchterm%' and threadparent='0' order by telapsed DESC limit $start, 50";
  $getthreads2=mysql_query($getthreads) or die("Could not get threads"); 
  while($getthreads3=mysql_fetch_array($getthreads2))
  {
    print "<tr class='forumrow'><td style='border-bottom:solid 1px #000000'><A href='index.php?forumID=$getthreads3[postforum]&ID=$getthreads3[ID]'>$getthreads3[title]</a></td>";
    print "<td style='border-bottom:solid 1px #000000'>Last Post by: <b>$getthreads3[lastpost]</b> at <br>$getthreads3[timepost]</td></tr>";
  }
  print "</table>";
  $prev=$start-50;
  $next=$start+50;
  $num=mysql_num_rows($getthreads2);
  print "<table class='maintable'>";
  print "<tr class='regrow'><td>";
  print "<center>";
  if($start>=50)
  {
     print "<a href='search.php?searchterm=$searchterm&start=$prev'><< Prev</a>&nbsp;&nbsp;&nbsp;";
  }
  if($start<=$num-50)
  {
     print "<a href='search.php?searchterm=$searchterm&start=$next'>Next >></a>";
  }
  print "</td></tr></table>";
  

 

}
else
{
  print "<br><br><br><br><table style='background-image:url(../images/transp.png); border: solid 1px #000000; width: 500px;  padding-bottom: 10px'>";
  print "<tr class='headline'><td><div style='background-image: url(../images/transpblack.png); padding: 2px'><center><strong class='style1'>Search</strong></center></div></td></tr>";
  print "<tr class='forumrow'><td>";
  print "<form acton='search.php' method='post'>";
  print "Search : <input type='text' name='searchterm' size='20'>&nbsp;<input type='submit' name='submit' value='search'></form></td></tr></table>";

} 

?>
<center><strong class='style1'>&copy; AXE</strong></center>


</center></body></html>  